summaryrefslogtreecommitdiffstats
path: root/src/hid_core/resources/touch_screen/gesture.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/hid_core/resources/touch_screen/gesture.h')
-rw-r--r--src/hid_core/resources/touch_screen/gesture.h87
1 files changed, 16 insertions, 71 deletions
diff --git a/src/hid_core/resources/touch_screen/gesture.h b/src/hid_core/resources/touch_screen/gesture.h
index 32e9a8690..d92912bb6 100644
--- a/src/hid_core/resources/touch_screen/gesture.h
+++ b/src/hid_core/resources/touch_screen/gesture.h
@@ -1,87 +1,32 @@
-// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
-// SPDX-License-Identifier: GPL-2.0-or-later
+// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
-#include <array>
+#include <mutex>
#include "common/common_types.h"
-#include "hid_core/resources/controller_base.h"
-#include "hid_core/resources/touch_screen/touch_types.h"
-
-namespace Core::HID {
-class EmulatedConsole;
-}
+#include "core/hle/result.h"
namespace Service::HID {
-struct GestureSharedMemoryFormat;
+class TouchResource;
-class Gesture final : public ControllerBase {
+/// Handles gesture request from HID interfaces
+class Gesture {
public:
- explicit Gesture(Core::HID::HIDCore& hid_core_);
- ~Gesture() override;
+ Gesture(std::shared_ptr<TouchResource> resource);
+ ~Gesture();
- // Called when the controller is initialized
- void OnInit() override;
+ Result Activate();
+ Result Activate(u64 aruid, u32 basic_gesture_id);
- // When the controller is released
- void OnRelease() override;
+ Result Deactivate();
- // When the controller is requesting an update for the shared memory
- void OnUpdate(const Core::Timing::CoreTiming& core_timing) override;
+ Result IsActive(bool& out_is_active) const;
private:
- // Reads input from all available input engines
- void ReadTouchInput();
-
- // Returns true if gesture state needs to be updated
- bool ShouldUpdateGesture(const GestureProperties& gesture, f32 time_difference);
-
- // Updates the shared memory to the next state
- void UpdateGestureSharedMemory(GestureProperties& gesture, f32 time_difference);
-
- // Initializes new gesture
- void NewGesture(GestureProperties& gesture, GestureType& type, GestureAttribute& attributes);
-
- // Updates existing gesture state
- void UpdateExistingGesture(GestureProperties& gesture, GestureType& type, f32 time_difference);
-
- // Terminates exiting gesture
- void EndGesture(GestureProperties& gesture, GestureProperties& last_gesture_props,
- GestureType& type, GestureAttribute& attributes, f32 time_difference);
-
- // Set current event to a tap event
- void SetTapEvent(GestureProperties& gesture, GestureProperties& last_gesture_props,
- GestureType& type, GestureAttribute& attributes);
-
- // Calculates and set the extra parameters related to a pan event
- void UpdatePanEvent(GestureProperties& gesture, GestureProperties& last_gesture_props,
- GestureType& type, f32 time_difference);
-
- // Terminates the pan event
- void EndPanEvent(GestureProperties& gesture, GestureProperties& last_gesture_props,
- GestureType& type, f32 time_difference);
-
- // Set current event to a swipe event
- void SetSwipeEvent(GestureProperties& gesture, GestureProperties& last_gesture_props,
- GestureType& type);
-
- // Retrieves the last gesture entry, as indicated by shared memory indices.
- [[nodiscard]] const GestureState& GetLastGestureEntry() const;
-
- // Returns the average distance, angle and middle point of the active fingers
- GestureProperties GetGestureProperties();
-
- GestureState next_state{};
- GestureSharedMemoryFormat* shared_memory;
- Core::HID::EmulatedConsole* console = nullptr;
-
- std::array<Core::HID::TouchFinger, MAX_POINTS> fingers{};
- GestureProperties last_gesture{};
- s64 last_update_timestamp{};
- s64 last_tap_timestamp{};
- f32 last_pan_time_difference{};
- bool force_update{false};
- bool enable_press_and_tap{false};
+ mutable std::mutex mutex;
+ std::shared_ptr<TouchResource> touch_resource;
};
+
} // namespace Service::HID